# Maintainer: Tim Meusel <tim@bastelfreak.de>

_gemname='minitest-stub-const'
pkgname="ruby-${_gemname}"
pkgver=0.6
pkgrel=2
pkgdesc='Stub constants for the duration of a block in MiniTest.Similar to RSpecs stub_const'
arch=('any')
url='https://github.com/adammck/minitest-stub-const'
license=('MIT')
depends=('ruby')
makedepends=('ruby-rake')
checkdepends=('ruby-minitest')
options=('!emptydirs')
source=("${url}/archive/v${pkgver}/${_gemname}-v${pkgver}.tar.gz")
sha512sums=('1363d85a75d84e2643eddd676d47f0969700854433697731f9896298ec53158f046e3e89ca3d1cbbe85f2cac037c51b5982c0f2f75c405b190d2501afb598a71')

prepare() {
  cd "${srcdir}/${_gemname}-${pkgver}"
}

build() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  gem build "${_gemname}.gemspec"
}

check() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  rake test
}

package() {
cd "${srcdir}/${_gemname}-${pkgver}"
  local _gemdir="$(gem env gemdir)"
  gem install --verbose --ignore-dependencies --no-user-install --install-dir "${pkgdir}/${_gemdir}" --bindir "${pkgdir}/usr/bin" "${_gemname}-${pkgver}.gem"

  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/"

  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"

  rm -rf "${pkgdir}/${_gemdir}/cache"
 }
